home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
LOGIC Apps
/
Logic-APPLE_II_APPS.iso
/
mac
/
LOGIC Apple II 5.25" Library - ProDOS
/
PRO018.dsk
/
ALARM.CLOCK.bas
next >
Wrap
BASIC Source File
|
2012-02-16
|
6KB
|
130 lines
100 REM A L A R M C L O C K
110 REM BY KEITH FALKNER 1986
120 REM
130 D$ = CHR$(4): REM ctrl-D
140 KS = 49168: REM KB strobe
150 DIM F$(36)
160 PRINT CHR$(21)
170 TEXT : HOME : NORMAL : SPEED= 255
180 READ Z$: IF Z$ < >"*" THEN PRINT Z$: GOTO 180
190 PRINT D$"BLOAD ALARM.OBJ"
200 TM = 700: REM M/L program
210 REM
220 REM Here is how to fine-tune the clock, in case it is running
230 REM fast or slow on your particular computer. The idea here
240 REM is that we use the 'vertical blanking' signal as a source
250 REM of 60-cycle pulses. The actual rate varies a little bit
260 REM from a true 60-cycle signal, so you can adjust the rate
270 REM at which the clock ticks. Each second, we count down
280 REM from 60 to 0, but on the first second of every minute,
290 REM we count down not from 60, but from 65. With carefully
300 REM chosen POKE instructions, which you can add to the program
310 REM at this point, you can fine-tune the clock so that it keeps
320 REM perfect time on your computer. Here are the current POKEs:
330 REM POKE 708,60 : rem reset to 60 every second.
340 REM POKE 707,60 : rem reset to 60 every tenth second.
350 REM POKE 706,65 : rem reset to 65 every minute.
360 REM POKE 705,54 : rem reset to 54 every tenth minute.
370 REM POKE 704,62 : rem reset to 62 every hour.
380 REM POKE 703,57 : rem reset to 65 every tenth hour.
390 REM The above lines show the POKEs in decreasing order of
400 REM power. For example, if you change the POKE to 708 to a
410 REM number a little bit less, you speed up the clock a lot.
420 REM If you change the POKE to 704 to a number a little bit
430 REM more, you slow the clock down just a tiny bit.
440 PRINT D$"PREFIX": INPUT P$
450 PRINT D$"OPEN"P$",TDIR"
460 PRINT D$"READ"P$: INPUT Z$,Z$,Z$
470 INPUT Z$: IF Z$ = "" GOTO 490
480 F = F +1:F$(F) = MID$ (Z$,2,15): IF F <36 GOTO 470
490 PRINT D$"CLOSE"
500 PRINT "Press the space-bar to continue: ";
510 POKE KS,0: GET K$
520 VTAB 23: PRINT : HOME
530 IF K$ = CHR$(3) OR K$ = CHR$(27) THEN PRINT D$"-STARTUP"
540 FP = 0
550 INVERSE : VTAB 22: PRINT "SELECT WITH ARROWS, THEN PRESS <RETURN>"
560 NORMAL : PRINT " YOU ARE CHOOSING THE PROGRAM THAT"
570 PRINT " WILL BE RUN WHEN THE ALARM GOES OFF.";
580 VTAB 1: HTAB 1: INVERSE : PRINT "PROGRAMS ON DISK "P$; TAB( 39)"": NORMAL
590 DEF FN FL(I) = I +2 -18 *(I >18)
600 DEF FN FC(I) = 3 +22 *(I >18)
610 FOR I = 1 TO F: VTAB FN FL(I): HTAB FN FC(I): PRINT F$(I): NEXT
620 FC = 3
630 IF FC <1 THEN FC = F
640 IF FC >F THEN FC = 1
650 INVERSE : VTAB FN FL(FC): HTAB FN FC(FC): PRINT F$(FC): NORMAL
660 VTAB 22: HTAB 40: POKE KS,0: GET K$
670 NORMAL : VTAB FN FL(FC): HTAB FN FC(FC): PRINT F$(FC)
680 K = ASC(K$ +" ")
690 FC = FC +(K = 32) +(K = 10) -(K = 11) +20 *(K = 21) -20 *(K = 8) + VAL(K$)
700 IF K < >13 GOTO 630
710 CM$ = "- " +F$(FC)
720 HOME : VTAB 6: PRINT "Enter the current time as HHMMSS."
730 PRINT "(about 20 seconds from now): ";
740 ZL = 235959: GOSUB 1010
750 TI$ = RIGHT$( STR$(1000000 +Z),6)
760 PRINT : PRINT : PRINT "And the time for alarm as HHMMSS."
770 PRINT SPC( 28)":";
780 ZL = 235959: GOSUB 1010
790 TA$ = RIGHT$( STR$(1000000 +Z),6)
800 HOME : VTAB 6: PRINT " Current time is ";:Z$ = TI$: GOSUB 1230
810 PRINT : PRINT : PRINT " Alarm's set for ";:Z$ = TA$: GOSUB 1230
820 PRINT : PRINT : PRINT " This command will be issued:"
830 PRINT " "CM$
840 VTAB 22: PRINT "Press space bar at exactly ";
850 Z$ = TI$: GOSUB 1230: PRINT ". ";
860 POKE KS,0: GET K$
870 VTAB 21: PRINT : CALL -958
880 REM -> current on screen
890 VTAB 6: HTAB 21
900 CALL TM
910 VTAB 17: PRINT
920 IF TI$ = TA$ GOTO 950
930 PRINT " Alarm cancelled from keyboard."
940 POKE KS,0: GOTO 1390
950 PRINT " Alarm time has been reached."
960 PRINT D$CM$
970 GOTO 1390
980 REM
990 REM subroutine to get
1000 REM a number from keys
1010 Z = 0:ZW = 0: POKE KS,0
1020 GET K$: IF Z AND (K$ = CHR$(13)) THEN PRINT : RETURN
1030 IF K$ = CHR$(127) OR K$ = CHR$(8) GOTO 1070
1040 IF K$ <"0" OR K$ >"9" GOTO 1020
1050 ZT = Z *10 + VAL(K$): IF ZW = 6 OR ZT >ZL GOTO 1020
1060 PRINT K$;:Z = ZT:ZW = ZW +1: GOTO 1020
1070 IF ZW = 0 GOTO 1020
1080 PRINT CHR$(8)" " CHR$(8);
1090 ZW = ZW -1:Z = INT(Z/10): GOTO 1020
1100 REM subrroutine to get
1110 REM a string from keys
1120 Z$ = "": POKE KS,0
1130 GET K$: IF K$ = CHR$(13) THEN PRINT : RETURN
1140 IF K$ = CHR$(127) OR K$ = CHR$(8) GOTO 1180
1150 IF K$ <" " OR LEN(Z$) = ZL GOTO 1130
1160 IF K$ = >"a" AND K$ < = "z" THEN K$ = CHR$( ASC(K$) -32)
1170 PRINT K$;:Z$ = Z$ +K$: GOTO 1130
1180 IF Z$ = "" GOTO 1130
1190 PRINT CHR$(8)" " CHR$(8);
1200 Z$ = MID$ (Z$,1, LEN(Z$) -1): GOTO 1130
1210 REM subroutine to print
1220 REM time as HH:MM:SS
1230 PRINT LEFT$(Z$,2)":" MID$ (Z$,3,2)":" RIGHT$(Z$,2);: RETURN
1240 DATA This program is a real-time clock.,
1250 DATA There are three things you should do --,
1260 DATA 1. Enter the time as HHMMSS.
1270 DATA " e.g. 10:30 PM is 223000.",
1280 DATA 2. Enter the alarm-time as HHMMSS.,
1290 DATA 3. Select a program from those on
1300 DATA " this disk, and it will be run"
1310 DATA " when the alarm-time is reached.",
1320 DATA To cancel the alarm at any time before
1330 DATA the alarm 'goes off' just press any
1340 DATA key on the keyboard.,
1350 DATA "If you copy this program to another"
1360 DATA "disk, be sure to copy the machine-"
1370 DATA "language program ALARM.OBJ there too."
1380 DATA *: REM end of rules
1390 END